/*
 * G2ODataInfo.h
 *
 *  Created on: Sep 11, 2016
 *      Author: ubuntu
 */

#ifndef G2O_G2ODATAINFO_H_
#define G2O_G2ODATAINFO_H_

#include "G2OParse.h"
#include "../DataInfo.h"

class G2ODataInfo : public DataInfo
{
public:
	G2ODataInfo();
	virtual ~G2ODataInfo();
	virtual bool parse(unsigned char *buf, size_t len, int add_head, int add_tail);

	virtual void debugInfo();
	virtual int sendBuf(unsigned char *resBuf, size_t len, const char *key);
	virtual unsigned short get_type();
	virtual bool set_obdid(char *obdid, size_t len);
	virtual void writelog(const char *path);

protected:
	virtual void locallog();

private:
	int send_login_rsp(unsigned char *buf, size_t len, const char *key);
	int send_config_rsp(unsigned char *buf, size_t len);
	int send_warn_rsp(unsigned char *buf, size_t len);
	int send_travel_rsp(unsigned char *buf, size_t len);
	int send_packed_data_rsp(unsigned char *buf, size_t len);
	int send_beat_rsp(unsigned char *buf, size_t len);
	int send_upgrade_rsp(unsigned char *buf, size_t len);
	int send_unknown_000f(unsigned char *buf, size_t len);

	unsigned short rsp_crc16(unsigned char *buf, size_t len, size_t blen, const char *key, int *res);

private:
	struct g2o_msg msg;
	unsigned char *m_buf;
	size_t m_len;
	char m_obdid[13];
};

#endif /* G2O_G2ODATAINFO_H_ */
